package com.lsk.util;


import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayUserCertifyOpenInitializeRequest;
import com.alipay.api.response.AlipayUserCertifyOpenInitializeResponse;

public class AliIdentityAttestation {



   static String serverUrl="https://openapi.alipay.com/gateway.do";

    static String appId="";

    static String privateKey="";

    static String publicKey="";

    public static void identityAttestation(){

        AlipayClient alipayClient = new DefaultAlipayClient(serverUrl,appId,"your private_key","json","GBK",publicKey,"RSA2");

        AlipayUserCertifyOpenInitializeRequest request = new AlipayUserCertifyOpenInitializeRequest();

        AlipayUserCertifyOpenInitializeResponse response;

        try {
            request.setBizContent("{" +
                    "\"outer_order_no\":\"ZGYD201809132323000001234\"," +
                    "\"biz_code\":\"FACE\"," +
                    "\"identity_param\":\"{\\\"identity_type\\\":\\\"CERT_INFO\\\",\\\"cert_type\\\":\\\"IDENTITY_CARD\\\",\\\"cert_name\\\":\\\"收委\\\",\\\"cert_no\\\":\\\"260104197909275964\\\"}\"," +
                    "\"merchant_config\":\"{\\\"return_url\\\":\\\"xxx\\\"}\"," +
                    "\"face_contrast_picture\":\"xydasf==\"" +
                    "  }");
            response = alipayClient.execute(request);

            if(response.isSuccess()){
                System.out.println("调用成功");
            } else {
                System.out.println("调用失败");
            }

        } catch (AlipayApiException e) {
            e.printStackTrace();
        }

    }

}





